package file;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/**
 * @author wang hao
 * @date 2023-04-01 10:45
 */
public class Demo05 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String name = "abc我爱你中国";
        // 以当前启动默认的 字符集编码  获取byte数组
        byte[] bytes = name.getBytes();
        System.out.println(Arrays.toString(bytes));
        String string = new String(bytes, "utf-8");
        System.out.println(string);

        bytes = name.getBytes("GBK");
        System.out.println(Arrays.toString(bytes));
        string = new String(bytes, "GBK");
        System.out.println(string);
    }
}
